<include file="Public:header"/>
<body class="bgf6">
	<!-- 头部 -->
    <div class="header-container bgfff">
            <div class="weui-cell ih30">
                <div class="weui-cell__hd">

                </div>
                <div class="weui-cell__bd">
                	{$shop.name}
                </div>
            </div>
    </div>
    <!-- 内容 -->
    <div class="xq_container  m100vh bgfff">
        <div class="masonry">
        <if condition="!empty($list)">
            <volist name="list" id="v">
                <div class="imgitem">
                    <div class="">
                        <img class="w100" src="/{$v.pic}">
                    </div>
                </div>

            </volist>
        </if>
        </div>

    </div>
<include file="Public:footer"/>
<script type="text/javascript">

    $(function(){
        fenye();
    })
    var myp=1;


    function getJson(args) {
        $.get("{:U('Index/ajaxAlbum')}",{p:myp},function(data){
            putGoods(data,args);
        },'json');
    }

    function putGoods(data,args) {
        if(data.flag == 'success'){
            var shops = data.data;
            if((!shops || shops.length == 0 ) && args == "fenye"){
                $(".nomore").remove();
                $(".xq_container").append('<div class="texcen nomore">没有更多了！</div>');
            }
            var str ="";
            for(var index in shops){
                var shop = shops[index];
                str +='<div class="imgitem">\
                            <div class="">\
                                <img class="w100" src="'+shop.pic+'">\
                            </div>\
                        </div>' ;
            }
            if (args == "fenye") {
                $('.masonry').append(str);
            }else{
                $('.masonry').html(str);
            }
        }else{

        }
        if (args == "shouci") {
            fenye();
        }
    }

    function fenye(){
        var flag= true;//防止ajax请求期间，对此触发请求数据
        var $_zd = $(".item1").height();//获取每个单项的高度
        var length = 1;//定义预加载的数量，提前三个加载数据
        var $_par = $(".imglist");//获取包裹容器
        var winheight = $(window).height();//获取窗口高度
        var curpage = 1;//存储当前的页数v
        $(function(){
            $(window).on("scroll",function(e){
                if(flag){
                    var self = $(this);
                    var scrtop = self.scrollTop() + winheight;
                    var docheight = $_par.height();
                    if(scrtop > docheight - ( length * $_zd ) ){
                        flag = false;
                        myp = +myp +1;
                        getJson("fenye");
                    }
                }
            });
        });
    }
</script>
</body>
</html>